/**
 * Created by IntelliJ IDEA.
 * User: martlenn
 * Date: 24-Jan-2008
 * Time: 09:55:49
 */
package org.hkupp.db.accessors;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.HashMap;
/*
 * CVS information:
 *
 * $Revision$
 * $Date$
 */

/**
 * This class extends the ProteinTableAccessor.
 *
 * @author Lennart Martens
 * @version $Id$
 */
public class Protein extends ProteinTableAccessor {

    public Protein() {
    }
    
    public Protein(ResultSet aRs) throws SQLException {
        super(aRs);
    }

    public Protein(HashMap aData) throws SQLException {
        super(aData);
    }


    /**
     * Returns the Protein object for the specified accession,
     * or 'null' if none was found.
     *
     * @param aConn Connection to retrieve the Protein from.
     * @param aAccession String with the accession to look up.
     * @return  Protein for the specified accession, or 'null' if none was found.
     * @throws  SQLException when the database could not be contacted.
     */
    public static Protein findProtein(Connection aConn, String aAccession) throws SQLException {
        Protein result = null;
        Statement stat = aConn.createStatement();
        ResultSet rs = stat.executeQuery("select * from protein where accession_number = '" + aAccession + "'");
        while(rs.next()) {
            result = new Protein(rs);
        }
        return result;
    }
}
